<?php if (!defined('THINK_PATH')) exit(); /*a:4:{s:83:"D:\PHP\WWW\workspace\2018\tp5\public/../application/index\view\fruit_shop\show.html";i:1520580081;s:64:"D:\PHP\WWW\workspace\2018\tp5\application\index\view\layout.html";i:1520577863;s:75:"D:\PHP\WWW\workspace\2018\tp5\application\index\view\fruit_shop\header.html";i:1520577200;s:75:"D:\PHP\WWW\workspace\2018\tp5\application\index\view\fruit_shop\footer.html";i:1520577750;}*/ ?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>主界面</title>
    <link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap-theme.css" rel="stylesheet">
    <link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.css" rel="stylesheet">
    <script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.js"></script>
    <script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<style>
    .container{
        margin-top: 32px;
        text-align: center;


    }
    .control-label{
        font-size: 13px;
    }
    th{
        text-align: center;
    }
    td{
        vertical-align: middle !important;
    }
    .new{
        display: block;
        margin-bottom: 24px;
    }
    form{
        text-align: left;
    }
</style>
<body>

<div class="container">
    <form class="form-inline" role="form">
        <div class="form-group">
            <label  for="bianhao">供应商编号：</label>
            <input type="text" class="form-control" id="bianhao" >
        </div>
        <div class="form-group">
            <label  for="mingcheng">供应商名称：</label>
            <input type="text" class="form-control" id="mingcheng" >
        </div>

        <button type="button" class="btn btn-primary" id="search">查询</button>
    </form>
    <button type="button" class="btn btn-default  new" data-toggle="modal" data-target="#myModal">新增</button>

    <table class="table table-bordered table-striped">

        <thead>
        <tr>
            <th>序号</th>
            <th>供应商编号</th>
            <th>供应商名称</th>
            <th>联系人</th>
            <th>联系电话</th>
            <th>联系地址</th>
            <th>备注</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        <?php if(is_array($data) || $data instanceof \think\Collection || $data instanceof \think\Paginator): $i = 0; $__LIST__ = $data;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?>
        <tr>
            <td class="first"><?php echo $vo['id']; ?></td>
            <td><?php echo $vo['count']; ?></td>
            <td><?php echo $vo['supplier']; ?></td>
            <td><?php echo $vo['contact']; ?></td>
            <td><?php echo $vo['phone']; ?></td>
            <td><?php echo $vo['address']; ?></td>
            <td><?php echo $vo['mark']; ?></td>
            <td>
                <button type="button"  count="<?php echo $vo['count']; ?>"  mark="<?php echo $vo['mark']; ?>" supplier="<?php echo $vo['supplier']; ?>" contact="<?php echo $vo['contact']; ?>" phone="<?php echo $vo['phone']; ?>" address="<?php echo $vo['address']; ?>"  class="btn btn-primary update" data-toggle="modal" data-target="#myModal2">修改</button>
                <button type="button" class="btn btn-danger del" >删除</button>
            </td>
        </tr>
      <?php endforeach; endif; else: echo "" ;endif; ?>
        </tbody>
    </table>
    <?php echo $data->render(); ?>

</div>





<!-- 模态框（Modal） -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="myModalLabel">新增供应商</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" role="form">
                    <div class="form-group">
                        <label for="count" class="col-sm-2 control-label">供应商编号</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" id="count" name="count">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="supplier" class="col-sm-2 control-label">供应商名称</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" id="supplier" name="supplier">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="contact" class="col-sm-2 control-label">联系人</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" id="contact" name="contact">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="phone" class="col-sm-2 control-label">联系电话</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" id="phone" name="phone" >
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="address" class="col-sm-2 control-label">联系地址</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" id="address" name="address">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="mark" class="col-sm-2 control-label">备注</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" id="mark" name="mark">
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" id="add">添加</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>







<input type="hidden" value="" id="info_id">
<!-- 模态框（Modal） -->
<div class="modal fade" id="myModal2" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">

    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="myModalLabel2">修改信息</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" role="form">
                    <div class="form-group">
                        <label for="count" class="col-sm-2 control-label">供应商编号</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" id="count2" name="count2">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="supplier" class="col-sm-2 control-label">供应商名称</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" id="supplier2" name="supplier2">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="contact" class="col-sm-2 control-label">联系人</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" id="contact2" name="contact2">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="phone" class="col-sm-2 control-label">联系电话</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" id="phone2" name="phone2" >
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="address" class="col-sm-2 control-label">联系地址</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" id="address2" name="address2">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="mark" class="col-sm-2 control-label">备注</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" id="mark2" name="mark2">
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" id="add2">修改</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>



</body>
</html>
<script>
    $(function () {
        //添加
        $("#add").click(function () {
            $.post("http://localhost/workspace/2018/tp5/public/index/info/add",{
                "count":$("#count").val(),
                "supplier":$("#supplier").val(),
                "contact":$("#contact").val(),
                "phone":$("#phone").val(),
                "address":$("#address").val(),
                "mark":$("#mark").val()
            },function (data) {
                if(data=="ok"){
                    alert("添加成功");
                    $('#myModal').modal('hide');
                    history.go();

                }
            })
        });

        //更新

        $(".update").click(function(){
            $("#info_id").val($(this).parent().siblings(".first").html());
            $("#count2").val($(this).attr("count"));
            $("#supplier2").val($(this).attr("supplier"));
            $("#contact2").val($(this).attr("contact"));
            $("#phone2").val($(this).attr("phone"));
            $("#address2").val($(this).attr("address"));
            $("#mark2").val($(this).attr("mark"));
        });

        $("#add2").click(function () {
            $.post("http://localhost/workspace/2018/tp5/public/index/info/update",{
                "count":$("#count2").val(),
                "supplier":$("#supplier2").val(),
                "contact":$("#contact2").val(),
                "phone":$("#phone2").val(),
                "address":$("#address2").val(),
                "mark":$("#mark2").val(),
                "id":$("#info_id").val()
            },function (data) {
                if(data=="ok"){
                    alert("修改成功");
                    $('#myModal2').modal('hide');
                    history.go();

                }
            })
        });


        //删除

        $(".del").click(function(){
            $("#info_id").val($(this).parent().siblings(".first").html());
            $.post("http://localhost/workspace/2018/tp5/public/index/info/del",{
                "id": $("#info_id").val()
            },function (data) {
                if(data=="ok"){
                    alert("删除成功");

                    history.go();

                }
            })

        });



        //搜素

        $("#search").click(function(){
            var count=$("#bianhao").val();
            var supplier = $("#mingcheng").val();
            location.href="http://localhost/workspace/2018/tp5/public/index/fruit_shop/show?count="+count+"&supplier="+supplier;
        });
    })
</script>